package com.huihang.core.utils;
import lombok.Getter;
@Getter
public enum ResultCode {
    SUCCESS(2000, "成功"),
    RESOURCE_UPDATED(2001, "资源更新成功"),
    RESOURCE_DELETED(2002, "资源删除成功"),
    BATCH_OPERATION_SUCCESS(2003, "批量操作成功"),
    ASYNCHRONOUS_PROCESS_STARTED(2004, "异步处理已开始"),
    DATA_PROCESSED(2005, "数据处理成功"),
    SUBSCRIPTION_CREATED(2006, "订阅创建成功"),
    USER_ACTIVATED(2007, "用户激活成功"),
    PASSWORD_RESET(2008, "密码重置成功"),
    EMAIL_VERIFIED(2009, "邮箱验证成功"),
    SMS_VERIFIED(2011, "短信验证成功"),
    LICENSE_GRANTED(2012, "授权许可已授予"),
    TRANSACTION_COMMITTED(2013, "事务提交成功"),
    CACHE_CLEARED(2014, "缓存清除成功"),
    CONFIGURATION_SAVED(2015, "配置保存成功"),
    EXPORT_COMPLETED(2016, "导出完成"),
    IMPORT_COMPLETED(2017, "导入完成"),
    PAYMENT_RECEIVED(2018, "支付已接收"),
    REFUND_COMPLETED(2019, "退款完成"),
    TASK_COMPLETED(2020, "任务完成"),
    FILE_UPLOADED(2021, "文件上传成功"),
    FILE_DOWNLOADED(2022, "文件下载成功"),
    MESSAGE_SENT(2023, "消息发送成功"),
    NOTIFICATION_SENT(2024, "通知发送成功"),
    INVITATION_SENT(2025, "邀请发送成功"),
    ACCOUNT_LOCKED(2026, "账户锁定成功"),
    ACCOUNT_UNLOCKED(2027, "账户解锁成功"),
    SESSION_CREATED(2028, "会话创建成功"),
    SESSION_TERMINATED(2029, "会话终止成功"),
    TOKEN_GENERATED(2030, "令牌生成成功"),
    API_KEY_GENERATED(2031, "API密钥生成成功"),

    INCORRECT_PARAM(4010, "参数不正确"),
    VALIDATION_ERROR(4000, "数据验证错误"),
    VERSION_MISMATCH(4002, "版本不匹配"),
    DEPRECATED_API(4003, "已废弃的API接口"),
    ILLEGAL_OPERATION(4004, "非法操作"),
    DATA_FORMAT_ERROR(4005, "数据格式错误"),
    QUOTA_EXCEEDED(4006, "超出配额限制"),
    VERIFICATION_FAILED(4007, "验证失败"),
    ENTITY_LOCKED(4008, "实体已被锁定"),
    UNPARSEABLE_CONTENT(4009, "无法解析的内容"),
    TOO_MANY_REQUESTS(4290, "请求过于频繁，请稍后再试"),
    UNSUPPORTED_MEDIA_TYPE(4150, "不支持的媒体类型"),
    REQUEST_ENTITY_TOO_LARGE(4130, "请求体过大"),
    METHOD_NOT_ALLOWED(4050, "方法不允许"),
    IP_NOT_ALLOWED(4031, "不允许的IP地址"),
    USER_NOT_EXISTS(4040, "用户不存在"),
    NOT_FOUND(4040, "资源未找到"),
    CAPTCHA_ERROR(4011, "验证码错误"),
    CAPTCHA_TOO_MANY_REQUESTS_ERROR(4012, "验证码请求次数过多，请稍后重试！"),
    CLIENT_CLOSED_REQUEST(4999, "客户端关闭连接"),

    ERROR(5000, "失败"),
    TIMEOUT(5004, "操作超时"),
    INTERNAL_ERROR(5008, "系统内部错误"),
    SERVICE_UNAVAILABLE(5003, "服务不可用"),
    DEPENDENCY_SERVICE_UNAVAILABLE(5009, "依赖的服务不可用"),
    THIRD_PARTY_SERVICE_ERROR(5013, "第三方服务响应异常"),
    TRANSACTION_FAILED(5014, "事务处理失败"),
    CACHE_OPERATION_FAILED(5015, "缓存操作失败"),
    ENCRYPTION_DECRYPTION_ERROR(5016, "数据加密解密失败"),
    DATA_SYNC_FAILED(5017, "数据同步失败"),
    EMAIL_SENDING_FAILED(5018, "邮件发送失败"),
    SMS_SENDING_FAILED(5019, "短信发送失败"),
    PAYMENT_FAILED(5020, "支付失败"),
    TASK_EXECUTION_FAILED(5021, "任务执行失败"),
    NETWORK_FAILURE(5011, "网络连接失败"),
    SERVER_CLOSED_CONNECTION(5010, "服务器关闭连接"),
    CONFIGURATION_ERROR(5012, "配置错误"),
    EXTERNAL_SERVICE_FAIL(5002, "外部服务调用失败"),

    NO_LOGIN(6000, "未登录"),
    FAIL_LOGIN(6001,"登录失败,账户或密码错误！"),
    ACCOUNT_LOCKOUT(6002,"账户已锁定"),
    AUTHENTICATION_FAILED(6003, "认证失败"),
    INVALID_TOKEN(6004, "令牌无效"),
    TOKEN_EXPIRED(6005, "令牌过期"),


    NO_AUTH(7000, "没有权限"),
    ACCESS_DENIED(7002, "禁止访问"),
    OPERATION_DENIED(7001, "操作被拒绝"),
    SESSION_EXPIRED(6001, "会话过期"),

    UPLOAD_FAIL(5005, "文件上传失败"),
    DOWNLOAD_FAIL(5006, "文件下载失败"),
    DATABASE_ERROR(5007, "数据库操作失败");

    private final int code;
    private final String message;

    ResultCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getMessageByCode(int code) {
        for (ResultCode resultCode : ResultCode.values()) {
            if (resultCode.getCode() == code) {
                return resultCode.getMessage();
            }
        }
        return null;
    }
}